home *** CD-ROM | disk | FTP | other *** search
/ Compendium Deluxe 1 / LSD Compendium Deluxe 1.iso / a / programming / assembly / ppcount.lha / ppcount.s < prev   
Encoding:
Text File  |  1994-06-05  |  5.6 KB  |  428 lines

  1.     section    lard,code
  2.  
  3. code:    move.l    a0,Path
  4.     
  5.     IncDir    "DH0:Include/"
  6.     
  7.     include    "sc:MyReq.ii"
  8.     
  9.     move.l    #0,length
  10.     move.l    #0,files
  11.  
  12.     Lea    DosName,A1
  13.     Moveq    #0,D0
  14.     CALLEXEC    OpenLibrary
  15.     Move.l     D0,_DOSBase
  16.     Beq    Error
  17.  
  18.     bsr    _OpenMyReqs
  19.     beq    Error
  20.  
  21.     move.l    Path,a0
  22. .loop    add.l    #1,a0
  23.     cmp.b    #32,(a0)
  24.     bge    .loop
  25.     move.b    #0,(a0)
  26.     
  27.     move.l    Path,d1
  28.     move.l    #-2,d2
  29.     CALLDOS    Lock
  30.     move.l    d0,lock
  31.     beq    lock_err
  32.  
  33.     lea    Checking_Text,a2
  34.     bsr    setup_alert
  35.  
  36.     move.l    lock,d1
  37.     CALLDOS    CurrentDir
  38.     move.l    d0,oldlock
  39.     
  40.     move.l    lock,d1
  41.     move.l    #ExBlock,d2
  42.     CALLDOS    Examine
  43.     beq    lock_err
  44.  
  45.     cmp.l    #0,ExBlock+4
  46.     bmi    Single_File
  47.  
  48.     bsr    Get_Length
  49.     cmp.b    #27,d7
  50.     beq    Aborted
  51.     
  52.     cmp.l    #0,ExBlock+4
  53.     bmi    Finished
  54.     
  55. .next    move.l    lock,d1
  56.     move.l    #ExBlock,d2
  57.     CALLDOS    ExNext
  58.     beq    Finished
  59.     bsr    Get_Length
  60.     cmp.b    #27,d7
  61.     bne    .next
  62.     bra    Aborted
  63.     
  64. Finished    move.l    lock,d1
  65.     CALLDOS    UnLock
  66.  
  67.     move.l    oldlock,d1
  68.     CALLDOS    CurrentDir
  69.  
  70.     bsr    finish_alert
  71.  
  72.     bsr    Prepare_Final
  73.  
  74.     lea    Final_Text,a2
  75.     bsr    setup_alert
  76.     
  77. Bye    Move.l    _DOSBase,A1
  78.     CALLEXEC    CloseLibrary
  79.  
  80.     bsr    _CloseMyReqs
  81.  
  82. Error    Moveq    #0,D0
  83.     Rts
  84.  
  85. Aborted:    move.l    lock,d1
  86.     CALLDOS    UnLock
  87.  
  88.     move.l    oldlock,d1
  89.     CALLDOS    CurrentDir
  90.  
  91.     bsr    finish_alert
  92.  
  93.     lea    Aborted_text,a2
  94.     bsr    setup_alert
  95.     
  96.     Move.l    _DOSBase,A1
  97.     CALLEXEC    CloseLibrary
  98.     
  99.     Move.l    _IntuitionBase,A1
  100.     CALLEXEC    CloseLibrary
  101.  
  102.     Move.l    _GfxBase,a1
  103.     CALLEXEC    CloseLibrary
  104.  
  105.     Moveq    #0,D0
  106.     Rts
  107.  
  108.     *-------------------------------*
  109.  
  110. Get_Length:    move.l    #0,d7
  111.  
  112.     move.l    #ExBlock+8,d1
  113.     move.l    #MODE_OLDFILE,d2
  114.     CALLDOS    Open
  115.     beq    Error
  116.     
  117.     move.l    d0,handle
  118.  
  119.     move.l    handle,d1
  120.     move.l    #Temp,d2
  121.     move.l    #4,d3
  122.     CALLDOS    Read
  123.     cmp.l    #"PP20",Temp
  124.     bne    .NotPP
  125.  
  126.     move.l    #ExBlock+8,a0
  127.     move.w    #-1,d7
  128. .loop    add.w    #1,d7
  129.     cmp.w    #31,d7
  130.     beq    .stop
  131.     cmp.b    #0,(a0,d7.w)
  132.     bne    .loop    
  133.  
  134. .stop    Move.l    _MyReqWinRPort,a1
  135.     move.w    #1,d0
  136.     CALLGRAF    SetAPen
  137.  
  138.     Move.l    _MyReqWinRPort,a1
  139.     move.w    #10,d0
  140.     move.w    #41,d1
  141.     CALLGRAF    Move
  142.  
  143.     Move.l    _MyReqWinRPort,a1
  144.     move.l    #ClearLine,a0
  145.     move.w    #31,d0
  146.     CALLGRAF    Text
  147.     
  148.     Move.l    _MyReqWinRPort,a1
  149.     move.w    d7,d0
  150.     asl.w    #3,d0
  151.     move.w    #260,d1
  152.     sub.w    d0,d1
  153.     lsr.w    #1,d1
  154.     move.w    d1,d0
  155.     move.w    #41,d1
  156.     CALLGRAF    Move
  157.  
  158.     Move.l    _MyReqWinRPort,a1
  159.     move.l    #ExBlock+8,a0
  160.     move.w    d7,d0
  161.     CALLGRAF    Text
  162.  
  163.     move.l    handle,d1
  164.     move.l    #-4,d2
  165.     move.l    #OFFSET_END,d3    
  166.     CALLDOS    Seek
  167.     
  168.     move.l    handle,d1
  169.     move.l    #Temp,d2
  170.     move.l    #4,d3
  171.     CALLDOS    Read
  172.  
  173.     move.l    handle,d1
  174.     CALLDOS    Close
  175.  
  176.     move.l    Temp,d0
  177.     lsr.l    #8,d0
  178.     add.l    d0,length
  179.  
  180.     add.l    #1,files
  181.  
  182.     move.l    #0,d7
  183.  
  184.     rts        
  185.  
  186. .NotPP    move.l    handle,d1
  187.     CALLDOS    Close
  188.  
  189.     lea    ExBlock+8,a0
  190.     lea    flname1,a1
  191.     bsr    CopyName
  192.     lea    NotPP_text,a2
  193.     bsr    setup_alert
  194.     rts
  195.  
  196.  
  197. Single_File:    move.l    #0,d7
  198.  
  199.     move.l    Path,d1
  200.     move.l    #MODE_OLDFILE,d2
  201.     CALLDOS    Open
  202.     beq    Error
  203.     
  204.     move.l    d0,handle
  205.  
  206.     move.l    handle,d1
  207.     move.l    #Temp,d2
  208.     move.l    #4,d3
  209.     CALLDOS    Read
  210.     cmp.l    #"PP20",Temp
  211.     bne    .NotPP
  212.  
  213.     move.l    #ExBlock+8,a0
  214.     move.w    #-1,d7
  215. .loop    add.w    #1,d7
  216.     cmp.w    #31,d7
  217.     beq    .stop
  218.     cmp.b    #0,(a0,d7.w)
  219.     bne    .loop    
  220.  
  221. .stop    Move.l    _MyReqWinRPort,a1
  222.     move.w    #1,d0
  223.     CALLGRAF    SetAPen
  224.  
  225.     Move.l    _MyReqWinRPort,a1
  226.     move.w    #10,d0
  227.     move.w    #41,d1
  228.     CALLGRAF    Move
  229.  
  230.     Move.l    _MyReqWinRPort,a1
  231.     move.l    #ClearLine,a0
  232.     move.w    #31,d0
  233.     CALLGRAF    Text
  234.     
  235.     Move.l    _MyReqWinRPort,a1
  236.     move.w    d7,d0
  237.     asl.w    #3,d0
  238.     move.w    #260,d1
  239.     sub.w    d0,d1
  240.     lsr.w    #1,d1
  241.     move.w    d1,d0
  242.     move.w    #41,d1
  243.     CALLGRAF    Move
  244.  
  245.     Move.l    _MyReqWinRPort,a1
  246.     move.l    #ExBlock+8,a0
  247.     move.w    d7,d0
  248.     CALLGRAF    Text
  249.  
  250.     move.l    handle,d1
  251.     move.l    #-4,d2
  252.     move.l    #OFFSET_END,d3    
  253.     CALLDOS    Seek
  254.     
  255.     move.l    handle,d1
  256.     move.l    #Temp,d2
  257.     move.l    #4,d3
  258.     CALLDOS    Read
  259.  
  260.     move.l    handle,d1
  261.     CALLDOS    Close
  262.  
  263.     move.l    Temp,d0
  264.     lsr.l    #8,d0
  265.     add.l    d0,length
  266.  
  267.     add.l    #1,files
  268.  
  269.     move.l    #0,d7
  270.  
  271.     bra    Finished
  272.  
  273. .NotPP    move.l    handle,d1
  274.     CALLDOS    Close
  275.  
  276.     lea    ExBlock+8,a0
  277.     lea    flname1,a1
  278.     bsr    CopyName
  279.     lea    NotPP_text,a2
  280.     bsr    setup_alert
  281.  
  282.     Bra    Finished
  283.     
  284. CopyName:    
  285. .loop    move.b    (a0)+,(a1)+
  286.     cmp.b    #0,(a0)
  287.     bne    .loop
  288.     move.b    #0,(a1)
  289.     rts
  290.  
  291.     *-------------------------------*
  292.  
  293. lock_err:    lea    le_text,a2
  294.     bsr    setup_alert
  295.     bsr    Bye
  296.     rts
  297.  
  298.     *-------------------------------*
  299.  
  300. Prepare_Final:
  301.     lea    num1,a0
  302.     move.b    #"0",0(a0)
  303.     move.b    #"0",1(a0)
  304.     move.b    #"0",2(a0)
  305.     move.b    #"0",3(a0)
  306.     move.b    #"0",4(a0)
  307.     move.b    #"0",5(a0)
  308.     move.b    #"0",6(a0)
  309.     move.b    #"0",7(a0)
  310.     move.b    #"0",8(a0)
  311.  
  312.     move.l    length,d0
  313.  
  314. .l1    cmp.l    #100000000,d0
  315.     blt    .l2
  316.     add.b    #1,0(a0)
  317.     sub.l    #100000000,d0
  318.     bpl    .l1
  319. .l2    cmp.l    #10000000,d0
  320.     blt    .l3
  321.     add.b    #1,1(a0)
  322.     sub.l    #10000000,d0
  323.     bpl    .l2
  324. .l3    cmp.l    #1000000,d0
  325.     blt    .l4
  326.     add.b    #1,2(a0)
  327.     sub.l    #1000000,d0
  328.     bpl    .l3
  329. .l4    cmp.l    #100000,d0
  330.     blt    .l5
  331.     add.b    #1,3(a0)
  332.     sub.l    #100000,d0
  333.     bpl    .l4
  334. .l5    cmp.l    #10000,d0
  335.     blt    .l6
  336.     add.b    #1,4(a0)
  337.     sub.l    #10000,d0
  338.     bpl    .l5
  339. .l6    cmp.l    #1000,d0
  340.     blt    .l7
  341.     add.b    #1,5(a0)
  342.     sub.l    #1000,d0
  343.     bpl    .l6
  344. .l7    cmp.l    #100,d0
  345.     blt    .l8
  346.     add.b    #1,6(a0)
  347.     sub.l    #100,d0
  348.     bpl    .l7
  349. .l8    cmp.l    #10,d0
  350.     blt    .l9
  351.     add.b    #1,7(a0)
  352.     sub.l    #10,d0
  353.     bpl    .l8
  354. .l9    cmp.l    #1,d0
  355.     blt    .l10
  356.     add.b    #1,8(a0)
  357.     sub.l    #1,d0
  358.     bpl    .l9
  359.  
  360. .l10    cmp.b    #"0",0(a0)
  361.     bne    .s1
  362.     move.b    #" ",0(a0)
  363.     add.l    #1,a0
  364.     bra    .l10    
  365.  
  366. .s1    lea    num1,a0
  367.     cmp.b    #" ",8(a0)
  368.     bne    .s2
  369.     move.b    #"0",8(a0)
  370.         
  371. .s2    rts
  372.     
  373.     *-------------------------------*
  374.  
  375.     include    "sc:myreq.i"
  376.  
  377. _DOSBase        Dc.l    0
  378. DosName        DOSNAME
  379.  
  380. Path:        dc.l    0
  381.  
  382. lock:        dc.l    0
  383. oldlock:        dc.l    0
  384. length:        dc.l    0
  385. files:        dc.l    0
  386. handle:        dc.l    0
  387. Temp:        dc.l    0,0
  388. ClearLine:        dcb.b    31,32
  389.  
  390.         cnop    0,4
  391. ExBlock:        ds.b    260
  392.  
  393.     *-------------------------------*
  394.  
  395. le_text:    dc.b    1
  396.     dc.b    "** PP COUNT 1.0 **",0
  397.     dc.b    " ",0
  398.     dc.b    "CANT FIND DIRECTORY",0
  399.  
  400. Aborted_text:    
  401.     dc.b    1
  402.     dc.b    "** PP COUNT 1.0 **",0
  403.     dc.b    " ",0
  404.     dc.b    "Aborted",0
  405.  
  406. NotPP_text:    dc.b    1
  407.     dc.b    "** PP COUNT 1.0 **",0
  408.     dc.b    "File is not PowerPacked!",0
  409. flname1:    ds.b    40
  410.  
  411. Checking_Text:    
  412.     dc.b    0
  413.     dc.b    "** PP COUNT 1.0 **",0
  414.     dc.b    "Scanning File",0
  415.     dc.b    "",0
  416.  
  417. Final_Text:    
  418.     dc.b    1
  419.     dc.b    "** PP COUNT 1.0 **",0
  420.     dc.b    0
  421.     dc.b    "PowerPacked Length : "
  422. num1:    dc.b    "000000000",0
  423.  
  424.  
  425.     end
  426.  
  427.  
  428.